package com.modifymetrodemo.async;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.modifymetrodemo.R;
import com.modifymetrodemo.beans.ReactNativeBusinessInfo;
import com.modifymetrodemo.utils.TimeRecordUtils;

public class AsyncLoadBusinessParentActivity extends AppCompatActivity {

    public static MyReactActivityDelegate sMyReactActivityDelegate;

    private Button mBtnGotoRealLoadBusinessBundle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final ReactNativeBusinessInfo mChosenBusinessInfo  = new ReactNativeBusinessInfo(
                getIntent().getStringExtra("displayName"),
                getIntent().getStringExtra("bundleFilePath"),
                getIntent().getStringExtra("mainComponentName"));

        sMyReactActivityDelegate = new MyReactActivityDelegate(this);
        setContentView(R.layout.activity_async_load_buiness_parent);
        sMyReactActivityDelegate.onCreateInParentActivity(savedInstanceState);

        mBtnGotoRealLoadBusinessBundle = findViewById(R.id.btn_go_to_real_load_business_bundle);
        mBtnGotoRealLoadBusinessBundle.setOnClickListener(v -> {
            Intent intent = new Intent(AsyncLoadBusinessParentActivity.this,
                    AsyncLoadBusinessChildActivity.class);
            intent.putExtra("displayName",mChosenBusinessInfo.displayName);
            intent.putExtra("bundleFilePath",mChosenBusinessInfo.bundleFilePath);
            intent.putExtra("mainComponentName",mChosenBusinessInfo.mainComponentName);
            startActivity(intent);
            TimeRecordUtils.setStartTime();
        });
    }
}
